/*********************************
File name:  study1_analyses FINAL.do
DATE:		5/2019
PURPOSE:    This do file is for analyzing "ideological identity" 
            among rightists and leftists:			
INPUT: 		study1_COMPLETE_dataset.dta 
AUTHOR:     Omer Yair, Odelia Oshri
*********************************/

* Changing the working directory
cd "C:\Users\bronc\Desktop"

* Load data (.dta)
use "study1_COMPLETE_dataset.dta"

*****************
*** Main text ***
*****************

*** Table 1 - predicting In-bloc voting ***

*** Model 1 - Predicting In-bloc voteing for Right-wing respondents
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==3, r
outreg2 using Table_1.doc, replace se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) addstat(Pseudo R-squared, `e(r2_p)')

* Figure 1A: Predicted probabilities for a respondent in Model 1
marhis II_scale, points (11) atmeans percent

margin, atmeans at(II_scale= (0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1))
marginsplot

* 'dominance' analyses
domin inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==3, reg(logit) fitstat(e(r2_p)) 


*** Model 2 - Predicting In-bloc voteing for left-wing respondents
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==1, r
outreg2 using Table_1.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) addstat(Pseudo R-squared, `e(r2_p)')

* Figure 1B: Predicted predicted probabilities for a respondent in Model 2
marhis II_scale, points (11) atmeans percent
margin, atmeans at(II_scale= (0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1))

* 'dominance' analyses
domin inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==1, reg(logit) fitstat(e(r2_p)) 



*** Experiemental results ***
ttest anger, by (threat)
esize twosample anger, by (threat)

ttest concern, by (threat)
esize twosample concern, by (threat)

ttest enthusiasm, by (threat)
esize twosample enthusiasm, by (threat)




***************************************
*** Analyses in the Online Appendix ***
***************************************

***************
** Section C **
***************
*** Table C1 - Reactions to the Study 1 experiment ***

* Mode1 1 - Anger -  with two interactions
reg anger c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned age female relig_01 educ_01 if bloc_num!=2, r
outreg2 using Table_C1.doc, replace se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) 

* Figure 2 ('anger')
marhis II_scale, cate(threat) points (10) atmeans
graph save "anger", replace
marhis issues_aligned, cate(threat) points (10) atmeans
graph save "anger1", replace

* Retrodesign estimate:
retrodesign  .2733079 , se(.1263991) alpha(0.05) df(406)

* Calculating the coefficient for the Ideo. Identity scale in the threatening condition in Model 1
reg anger threat II_scale threat_II_scale right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned age female relig_01 educ_01 if bloc_num!=2, r
lincom II_scale + threat_II_scale


* Model 2 - concern - with two interactions
reg concern c.II_scale##i.threat right_bloc i.threat##c.issues_aligned  ///
econ_aligned halacha_aligned age female relig_01 educ_01 if bloc_num!=2, r
outreg2 using Table_C1.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +)

margin i.threat, atmeans at(II_scale= (0(0.1)1))

* Figure 2 ('concern')
marhis II_scale, cate(threat) points (10) atmeans
graph save "concern", replace
marhis issues_aligned, cate(threat) points (10) atmeans
graph save "concern1", replace

* Retrodesign estimate:
retrodesign  .5449825 , se(.1292303) alpha(0.05) df(406)

* Calculating the coefficient for the Ideo. Identity scale in the threatening condition in Model 2
reg concern threat II_scale threat_II_scale right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned age female relig_01 educ_01 if bloc_num!=2, r
lincom II_scale + threat_II_scale


* Mode1 3 - Enthusiasm - with two interactions
reg enthusiasm c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned age female relig_01 educ_01 if bloc_num!=2, r
outreg2 using Table_C1.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +)

* Figure 2 ('enthusiasm')
marhis II_scale, cate(threat) points (10) atmeans
graph save "enthusiasm", replace
marhis issues_aligned, cate(threat) points (10) atmeans
graph save "enthusiasm1", replace

* Combining the six graphs into Figure 2
grc1leg "anger" "concern" "enthusiasm" "anger1" "concern1" "enthusiasm1", legendfrom("anger") colfirst col(2) ycommon
graph save "Figure2", replace
erase "anger.gph"
erase "anger1.gph" 
erase "concern.gph" 
erase "concern1.gph" 
erase "enthusiasm.gph" 
erase "enthusiasm1.gph" 


* Retrodesign estimate:
retrodesign  -.538945 , se(.0825456) alpha(0.05) df(406)

* Calculating the coefficient for the Ideo. Identity scale in the threatening condition in Model 3
reg enthusiasm threat II_scale threat_II_scale right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned age female relig_01 educ_01 if bloc_num!=2, r
lincom II_scale + threat_II_scale


***************
** Section D **
***************

*** Table D2 - includes models w/o AIG, w/o alligned issues ***

*** Model 1 - Predicting In-bloc voteing for Right-wing respondents (no AIG)
logit inbloc_vote issues_aligned econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==3, r
outreg2 using Table_D2.doc, replace se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) addstat(Pseudo R-squared, `e(r2_p)')

*** Model 2 - Predicting In-bloc voteing for Right-wing respondents (no issues)
logit inbloc_vote II_scale econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==3, r
outreg2 using Table_D2.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) addstat(Pseudo R-squared, `e(r2_p)')

*** Model 3 - Predicting In-bloc voteing for Right-wing respondents (both AIG and issues)
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==3, r
outreg2 using Table_D2.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) addstat(Pseudo R-squared, `e(r2_p)')

*** Model 4 - Predicting In-bloc voteing for left-wing respondents (no AIG)
logit inbloc_vote issues_aligned econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==1, r
outreg2 using Table_D2.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) addstat(Pseudo R-squared, `e(r2_p)')

*** Model 5 - Predicting In-bloc voteing for left-wing respondents (no issues)
logit inbloc_vote II_scale econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==1, r
outreg2 using Table_D2.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) addstat(Pseudo R-squared, `e(r2_p)')

*** Model 6 - Predicting In-bloc voteing for left-wing respondents (both AIG and issues)
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==1, r
outreg2 using Table_D2.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) addstat(Pseudo R-squared, `e(r2_p)')




*** Matching (Entropy Balancing) ***

*** Table D6 - Matching analyses for Rightists ***
sum II_scale if bloc_num==3, d /*median = .5 */
gen II_right_high=1 if bloc_num==3 & II_scale>.5
replace II_right_high=0 if bloc_num==3 & II_scale<=.5
tab II_right_high

ebalance II_right_high issues_aligned econ_aligned halacha_aligned age female relig_01 educ_01, targets(1)
svyset [pweight=_webal]
* Model 1 - Model 2 in Table 1
svy: logit inbloc_vote i.II_right_high 
outreg2 using Table_D6.doc, replace se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) 

/*
** Matching for the experiment (result not shown in the main text) **
* Anger 
svy: reg anger c.II_right_high##i.threat 
svy: reg anger c.II_right_high##i.threat c.issues_aligned##i.threat
* Concern
svy: reg concern c.II_right_high##i.threat 
svy: reg concern c.II_right_high##i.threat c.issues_aligned##i.threat
* Enthusiasm
svy: reg enthusiasm c.II_right_high##i.threat 
svy: reg enthusiasm c.II_right_high##i.threat c.issues_aligned##i.threat
*/

*** Table D7 - Matching analyses for Leftists ***
sum II_scale if bloc_num==1, d /*median = .546875 */
gen II_left_high=1 if bloc_num==1 & II_scale>.546875 
replace II_left_high=0 if bloc_num==1 & II_scale<=.546875 
tab II_left_high

ebalance II_left_high issues_aligned econ_aligned halacha_aligned age female relig_01 educ_01, targets(1)
svyset [pweight=_webal]
* Model 1 - Model 4 in Table 1
svy: logit inbloc_vote i.II_left_high 
outreg2 using Table_D7.doc, replace se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) 

/*
** Matching for the experiment (result not shown in the main text) **
* Anger 
svy: reg anger c.II_left_high##i.threat 
svy: reg anger c.II_left_high##i.threat c.issues_aligned##i.threat
* Concern
svy: reg concern c.II_left_high##i.threat 
svy: reg concern c.II_left_high##i.threat c.issues_aligned##i.threat
* Enthusiasm
svy: reg enthusiasm c.II_left_high##i.threat 
svy: reg enthusiasm c.II_left_high##i.threat c.issues_aligned##i.threat
*/

*** Table D8 - The abridged 4-item AIG scale ***

* Model 1 - In-bloc voting among right-wing respondents
logit inbloc_vote short_AIG_scale issues_aligned econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==3, r
outreg2 using Table_D8.doc, replace se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) addstat(Pseudo R-squared, `e(r2_p)')
* Calculating the predicted probabilities for a respondent in Model 1
*margin, atmeans at(short_AIG_scale= (0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1))


* Model 2 - In-bloc voting among left-wing respondents
logit inbloc_vote short_AIG_scale issues_aligned econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==1, r
outreg2 using Table_D8.doc, append se dec(2) alpha (.001, .01, .05, .1) ///
symbol (***, **, *, +) addstat(Pseudo R-squared, `e(r2_p)')
* Calculating the predicted probabilities for a respondent in Model 2
* margin, atmeans at(short_AIG_scale= (0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1))




*** "Jackknifing" the Table 1 models ***
* Model 1 - Predicting In-bloc voteing for Right-wing respondents
logit inbloc_vote II_scale econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==3, r
logit inbloc_vote II_scale issues_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==3, r
logit inbloc_vote II_scale issues_aligned econ_aligned ///
age female relig_01 educ_01 if bloc_num==3, r
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
female relig_01 educ_01 if bloc_num==3, r
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age relig_01 educ_01 if bloc_num==3, r
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age female educ_01 if bloc_num==3, r
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age female relig_01 if bloc_num==3, r

*** Model 2 - Predicting In-bloc voteing for left-wing respondents
logit inbloc_vote II_scale econ_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==1, r
logit inbloc_vote II_scale issues_aligned halacha_aligned ///
age female relig_01 educ_01 if bloc_num==1, r
logit inbloc_vote II_scale issues_aligned econ_aligned ///
age female relig_01 educ_01 if bloc_num==1, r
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
female relig_01 educ_01 if bloc_num==1, r
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age relig_01 educ_01 if bloc_num==1, r
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age female educ_01 if bloc_num==1, r
logit inbloc_vote II_scale issues_aligned econ_aligned halacha_aligned ///
age female relig_01 if bloc_num==1, r


*** "Jackknifing" the Table C1 models ***
* Model 1 - Anger -  with two interactions
reg anger c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
halacha_aligned age female relig_01 educ_01 if bloc_num!=2, r
reg anger c.II_scale##i.threat right_bloc i.threat##c.issues_aligned econ_aligned ///
age female relig_01 educ_01 if bloc_num!=2, r
reg anger c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned female relig_01 educ_01 if bloc_num!=2, r
reg anger c.II_scale##i.threat right_bloc i.threat##c.issues_aligned  ///
econ_aligned halacha_aligned age relig_01 educ_01 if bloc_num!=2, r
reg anger c.II_scale##i.threat right_bloc i.threat##c.issues_aligned  ///
econ_aligned halacha_aligned age female educ_01 if bloc_num!=2, r
reg anger c.II_scale##i.threat right_bloc i.threat##c.issues_aligned  ///
econ_aligned halacha_aligned age female relig_01 if bloc_num!=2, r


* Model 2 - Concern -  with two interactions
reg concern c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
halacha_aligned age female relig_01 educ_01 if bloc_num!=2, r
reg concern c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned age female relig_01 educ_01 if bloc_num!=2, r
reg concern c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned female relig_01 educ_01 if bloc_num!=2, r
reg concern c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned age relig_01 educ_01 if bloc_num!=2, r
reg concern c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned age female educ_01 if bloc_num!=2, r
reg concern c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned age female relig_01 if bloc_num!=2, r


* Model 3 - Enthusiasm -  with two interactions
reg enthusiasm c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
halacha_aligned age female relig_01 educ_01 if bloc_num!=2, r
reg enthusiasm c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned age female relig_01 educ_01 if bloc_num!=2, r
reg enthusiasm c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned female relig_01 educ_01 if bloc_num!=2, r
reg enthusiasm c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned age relig_01 educ_01 if bloc_num!=2, r
reg enthusiasm c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned age female educ_01 if bloc_num!=2, r
reg enthusiasm c.II_scale##i.threat right_bloc i.threat##c.issues_aligned ///
econ_aligned halacha_aligned age female relig_01 if bloc_num!=2, r


***************
** Section I **
***************

*******************************
** Analyses among Centerists **
*******************************

** economic issue intensity (folding the soc_cap item)
gen econ_intensity=1 if q12==1 | q12==4
replace econ_intensity=0 if q12==2 | q12==3
tab econ_intensity soc_cap

** Halacha issue intensity (folding the halacha item)
gen halacha_intensity=1 if q11==1 | q11==3
replace halacha_intensity=0 if q11==2 
tab halacha_intensity halacha


* Model 1 - only ideological identity 
logit center_vote_int II_scale if bloc_num==2, r
* Model 2 - with issue-based ideology 
logit center_vote_int II_scale ideo_issues if bloc_num==2, r
* Model 3 - with all covariates
logit center_vote_int II_scale ideo_issues econ_intensity halacha_intensity ///
age female relig_01 educ_01 if bloc_num==2, r


